package com.example.demo.common;

import com.example.demo.entity.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class GetUserSessionTools {
    public static UserInfo getLoginUser(HttpServletRequest request) {

        HttpSession session = request.getSession(false);

        if (session != null && session.getAttribute(ApplicationVariable.SESSION_KEY_USERINFO) != null) {
            return (UserInfo) session.getAttribute(ApplicationVariable.SESSION_KEY_USERINFO);

        }
        return null;
    }
}
